package com.ruoyi.rsikManage.mapper;

import com.ruoyi.electricity.domain.DTO.HourlyData;
import com.ruoyi.rsikManage.domain.AlarmEvent;
import com.ruoyi.rsikManage.domain.AlarmEventDto;
import com.ruoyi.rsikManage.domain.TAlarms;
import com.ruoyi.rsikManage.domain.vo.AlarmUrlVo;
import com.ruoyi.rsikManage.domain.vo.AlarmtoSiteVo;
import com.ruoyi.rsikManage.domain.vo.ChartVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Mapper
public interface AlarmEventMapper {
    void insertAlarmEvent(HashMap<String, Object> param);

    int insertAlarm(AlarmEvent alarmEvent);
    int insertAlarmBatch(@Param("alarmEvents") List<AlarmEvent> alarmEvents);

    List<AlarmEvent> selectPageAlarmEvent(AlarmEvent alarmEvent);

    boolean updateAlarmEvent(Map<String, Object> param);

    int deleteAlarmEvent(@Param("ids") Long[] ids);

    int deleteAlarmEvent2(@Param("ids") Long[] ids);

    int updateDispose(Map<String, Object> param);

    List<AlarmEvent> selectCondition(AlarmEvent alarmEvent);

    List<AlarmEventDto> selectApproal(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<Map> selectAlarmEventByTimeandApeId(@Param("apeId") String apeId, @Param("startTime1") Date startTime1, @Param("endTime1") Date endTime1);

    List<AlarmEvent> selectAll(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<AlarmEvent> selectByIds(@Param("apeList") List<String> apeList);

    List<Map> selectAlarmNumCount(@Param("startTime") String startTime, @Param("endTime") String endTime);

    List<Map> selectAlarmNumCountV2(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("unitCodes") List<Long> unitCodes);


    Map<String, Object> selectEveryTypeNum(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("alarmLevel") int i);

    Map<String, Object> selectEveryTypeNumForUnitCodes(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime,
                                                       @Param("alarmLevel") int i,@Param("unitCodes") List<Long> unitCodes);


    int selectDictSize(String s);

    String selectDictContent(@Param("dictType") String dictType, @Param("alarmLevel") String alarmLevel);

    List<Map> selectChildNum();

    Map<String, Object> selectChildContent(String dictValue);

    int selectNum(String tVideoChildLevel);


    int selectByApproveSize();

    Map<String, Object> selectApproveCount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("approve") String strFori);

    Map<String, Object> selectByApproveValue(@Param("approve") String approve);

    List<ChartVo> selectDateCount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("approve") String approve);

    Map<String, Object> selectPointNum();

    List<String> selectAlarmTypeName();

    Map<String, Object> selectCountDay();

    Map<String, Object> selectCountLeft(@Param("name") String name);

    Map<String, Object> selectTypeAndName(@Param("alarmLevel") int i, @Param("alarmTypeName") String s);

    List<Map> selectUrlImage(@Param("alarmTypeName") String name);

    List<String> selectStandMontior(String ids);

    List<AlarmtoSiteVo> selectStandsPlace();

    List<AlarmtoSiteVo> selectByDicValue(String dicValue);

    List<AlarmtoSiteVo> selectByid(String id);

    List<AlarmtoSiteVo> selectByDeviceId(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("monitorId") String monitorId);

    List<AlarmUrlVo> selectName();

    List<String> selectByName();

    List<String> selectByNames(String name);

    List<AlarmUrlVo> selectNumByName();

    List<AlarmUrlVo> selectFiveTypes(@Param("alarmLevel") String alarmLevel, @Param("alarmType") String alarmType);

    List<String> selectLevel();

    List<String> selectType();

    List<Map> selectByType();

    List<AlarmUrlVo> selectThreeDayData(@Param("alarmLevel") String alarmLevel, @Param("alarmType") String alarmType);

    List<AlarmUrlVo> selectSevenDayData(@Param("alarmLevel") String alarmLevel, @Param("alarmType") String alarmType);

    List<AlarmUrlVo> selectFifteenDayData(@Param("alarmLevel") String alarmLevel, @Param("alarmType") String alarmType);

    List<AlarmtoSiteVo> selectBymonitorIds(@Param("stringList") List<String> stringList);

    List<AlarmtoSiteVo> selectByDeviceIds(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("stringList") List<String> stringList);

    List<AlarmtoSiteVo> selectByDeviceIdsForUnitCodes(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime,
                                                      @Param("stringList") List<String> stringList,@Param("unitCodes") List<Long> unitCodes);


    List<AlarmUrlVo> selectUrls(@Param("alarmLevel") String s1, @Param("alarmType") String s);

    @Select("SELECT DATE_FORMAT(alarm_time, '%Y-%m-%d %H') AS hour, COUNT(*) AS totalCount " +
            "FROM t_alarms " +
            "WHERE alarm_time >= #{startTime} " +
            "  AND alarm_time <= #{endTime} " +
            "GROUP BY hour " +
            "ORDER BY hour ASC")

    List<HourlyData> getHourlyDataQuery(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    @Select("SELECT DATE_FORMAT(alarm_time, '%Y-%m-%d %H') AS hour, COUNT(*) AS totalCount" +
            "FROM t_alarms"  +
            "where handelStatus='3' "  +
            "AND alarm_time >= #{startTime}" +
            " AND alarm_time <= #{endTime}" +
            "GROUP BY hour" +
            "ORDER BY hour ASC")
    List<HourlyData> getHourlyDataQuery1(@Param("startTime")Date startTime, @Param("endTime")Date endTime);

    int insertInboundDataOftAlarm(Map map);

}
